define(function (require, exports, modlue) {
    //检测类
    var Auth = require('qd-auth-1.0');
    var Ajax = require('extendModel/AjaxReturn');

    //首页轮播图片加载
    Ajax.ajaxSimple("/index/articleList.html?nid=scrollPic", 'post', function (result) {
        var data = result.data;
        
        var len = data.length;
        var str = "";
        for (i = 0; i < len; i++) {
            str += "<li style='background:url(" + data[i].picPath + ") no-repeat center 0'><a href=" + data[i].url + " ></a></li>";
        }
        $(".banner_con").html(str);
        require.async('jQueryPlugins/jQueryFlexslider/jquery.flexslider-min', function () {
            $('.flexslider').flexslider({
                directionNav: true,
                pauseOnAction: false
            });
        })
    });

    require.async('jQueryPlugins/jQueryNews/news', function () {
        $('.newsticker').newsTicker({
            row_height: 50,
            max_rows: 1,
            speed: 600,
            direction: 'up',
            duration: 4000,
            autostart: 1,
            pauseOnHover: 0
        });
    })

    // 推荐的标
    // 首页-趣豆计划(普通标)
    Ajax.ajaxSimple("/indexBorrowInfo.html?type=usually","get",function(data){
    	var tpl = require("/themes/theme_default/media/tpl/home_newInvest.tpl");
    	var template = Handlebars.compile(tpl);
    	var html = template(data);
    	$("#index_invest_list").html(html);
    	//biaoInfoLb();
    })
    //Ajax.ajaxWithHandlebar("/indexBorrowInfo.html?type=usually", require("/themes/theme_default/media/tpl/home_invest.tpl"), $("#index_invest_list"));


    // 首页-0元购
    var enjoy_option = {};
    enjoy_option.callBackFunction = function(){
        knobFcn();
    };
    // 首页-体验标
  /*  Ajax.ajaxWithHandlebar("/indexBorrowInfo.html?type=experience", require("/themes/theme_default/media/tpl/home_experience_invest.tpl"), $(".taste_invest"),enjoy_option);
    Ajax.ajaxWithHandlebar("/indexBorrowInfo.html?type=deliverGoods", require("/themes/theme_default/media/tpl/home_zeroBuy.tpl"), $(".home_zeroBuy"),enjoy_option);

    Ajax.ajaxWithHandlebar("/indexBorrowInfo.html?type=recommend", require("/themes/theme_default/media/tpl/home_deliver_invest.tpl"), $(".deliver_invest"),enjoy_option);
*/
    // 投资排行
    // 总排行
    var option1 = {};
    Ajax.ajaxWithHandlebar("/index/rankList.html?rank=total", require("/themes/theme_default/media/tpl/home_rank.tpl"), $(".rank_total"), option1);

    // 日排行
    //var option2 = {};
    //Ajax.ajaxWithHandlebar("/index/rankList.html?rank=today", require("/themes/theme_default/media/tpl/home_rank.tpl"), $(".rank_today"), option2);

    // 理财动态
    var option3 = {};
    Ajax.ajaxWithHandlebar("/index/todayTenderList.html", require("/themes/theme_default/media/tpl/home_today_tender.tpl"), $(".today_tender"), option3);

    // 公告列表
    var option4 = {isAppend: false};
    Ajax.ajaxWithHandlebar("/index/articleList.html?nid=notice", require("/themes/theme_default/media/tpl/home_notice.tpl"), $("#index_notice_list"), option4);

    // 公告列表2
    var option41 = {isAppend: false};
    Ajax.ajaxWithHandlebar("/index/articleNoticeList.html", require("/themes/theme_default/media/tpl/home_noticeList.tpl"), $("#index_notice_list2"), option4);

    // 媒体报道列表
    var option5 = {isAppend: true};
    Ajax.ajaxWithHandlebar("/index/articleList.html?nid=news", require("/themes/theme_default/media/tpl/home_news.tpl"), $(".home_media"), option5);
    
    // 影漫专栏
    var option6 = {isAppend: false};
    Ajax.ajaxWithHandlebar("/index/articleList.html?nid=cartoon", require("/themes/theme_default/media/tpl/home_lyhjr.tpl"), $("#home_lyhjr_list"), option6);

    $("#backTop").live("click", function () {
        var _this = $(this);
        $('html,body').animate({scrollTop: 0}, 500, function () {
            _this.hide();
        });
    });
    $(window).scroll(function () {
        var htmlTop = $(document).scrollTop();
        if (htmlTop > 500) {
            $("#backTop").show();
        } else {
            $("#backTop").hide();
        }
    });

    $(".home_choose_ranklist").click(function(){
    	$(this).addClass("choose");
    	$(this).siblings().removeClass("choose");
    	var index = $(this).index()-1;
    	$(this).parent().siblings("ul").hide();
    	$(this).parent().siblings("ul").eq(index).show();
    });
    
    function biaoInfoLb(){
    	//$("#index_invest_list")  itoleft 
    	var showCounts = 3;
    	var target = $(".long");
    	var infos = target.children();
    	var infoLength =Math.floor(infos.length/showCounts);
    	var bIndex = 1;
    	var biaoInFlag;
    	
    	function toLeft(){
    		if(bIndex == 1) return;
    		bIndex--;
    		$(".long").css("margin-left",(-1024*(bIndex-1))+"px");
    	}
    	
    	function toRight(){
    		//注释方法适用于一直往右
    		/*target.animate({marginLeft:'-1024px'},1000,function(){
    			for(var i=0;i<showCounts;i++){
    				infos.eq(i).detach().appendTo(target);
    			}
    			target.css("marginLeft","0px");
    		});*/
    		if(bIndex == infoLength) return;
    		bIndex++;
    		$(".long").css("margin-left",(-1024*(bIndex-1))+"px");
    	}
    	
    	function dsqLb(){
    		if(infoLength<=1) return;
    		biaoInFlag = setInterval(function(){
    			if(bIndex == infoLength) bIndex = 0;
    			bIndex++;
    			$(".long").css("margin-left",(-1024*(bIndex-1))+"px");
    		},5000);
    	}
    	function clearDsqLb(){
    		if(infoLength<=1) return;
    		clearInterval(biaoInFlag);
    	}
    	
    	dsqLb();
    	$(".itoleft").click(function(){
    		clearDsqLb();
    		toLeft();
    		dsqLb();
    	});
    	$(".itoright").click(function(){
    		clearDsqLb();
    		toRight();
    		dsqLb();
    	});
    	target.parent().hover(function(){
    		clearDsqLb();
    	},function(){
    		dsqLb();
    	});
    	
    }
    
    require.async(['/plugins/flexSlider/flexslider.css','/plugins/flexSlider/jquery.flexslider-min.js'],function(){
    	$(".home_yhdImgList").flexslider({
			selector: "li img",
			reverse:true,
			useCSS:true,
			controlNav:true,
			directionNav:false,
			slideshowSpeed: 3000
    	});
    });
    /*S新手标圆形进度条*/
    require('/plugins/jquery.knob/jquery.knob.min');
    function knobFcn(){
    	$('.knob').each(function () {
    		var val = parseInt($(this).val());
    		if (val == 100) {
    			var isIE = function (ver) {
    				var b = document.createElement('b');
    				b.innerHTML = '<!--[if IE ' + ver + ']><i></i><![endif]-->';
    				return b.getElementsByTagName('i').length === 1;
    			};
    			if (isIE(8)) {
    				$(this).next().addClass("investComplete100");
    			}
    		}
    		$(this).attr("data-fgColor", "#da4453");
    	});
    	$('.knob').knob({
    		'thickness': .1,
    		'readOnly':true,
    		format: function(v) {
                return v+"%";
    		}

    	});
    }
    //knobFcn();
    /*E新手标圆形进度条*/
});


          